package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	start := time.Now()

	concurrency := 10000

	var wg sync.WaitGroup
	wg.Add(concurrency)
	results := make(chan int, concurrency)

	var count int

	for i := 0; i < concurrency; i++ {
		go func(id int) {
			defer wg.Done()

			count++

			results <- count
		}(i)
	}

	wg.Wait()
	close(results)

	elapsed := time.Since(start)
	fmt.Println("程序耗时:", elapsed)

	// for result := range results {
	// 	fmt.Println("更新结果:", result)
	// }
}
